package com.example.javastream.demo;

import java.util.stream.Stream;

public class StatisticEndOps {
    public static void main(String[] args) {
        Stream<Integer> integerStream = Stream.of(1, 2, 3, 4, 5);
        // 最大、最小
        Integer max = integerStream.max((e1, e2) -> e1 - e2).get();
        System.out.println(max);

        System.out.println("1==============");
        integerStream = Stream.of(1, 2, 3, 4, 5);
        // 总数
        long count = integerStream.count();
        System.out.println(count);

        System.out.println("2==============");
        integerStream = Stream.of(1, 2, 3, 4, 5);
        // 第一个元素，任意元素
        Integer first = integerStream.findFirst().get();
        System.out.println(first);
        integerStream = Stream.of(1, 2, 3, 4, 5);
        Integer any = integerStream.findAny().get();
        System.out.println(any);
    }
}
